import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:fluttermodule/WelcomePage.dart';
import 'package:fluttermodule/WelcomePage11.dart';
import 'package:fluttermodule/routes.dart';

void main() => runApp(MyApp(routeName: window.defaultRouteName));
//void main() => runApp(_showForRoute(window.defaultRouteName));

Widget _showForRoute(String routeName) {
  if (routeName == "/welcomePage") {
    return layout();
  } else {
    return MaterialApp(
      title: "234",
      home: MyHomePage(title: "welcomePage",),
    );
  }
}

Widget layout() {
  return MaterialApp(
    title: "123",
    home: Scaffold(
      appBar: AppBar(
        title: Text("首页"),
      ),
    ),
  );
}

class MyApp extends StatefulWidget {
  final routeName;
  MyApp({Key key,this.routeName}):super(key: key);
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      supportedLocales: [const Locale('zh', 'CH'), const Locale('en', 'US')],
      debugShowCheckedModeBanner: false, //去掉debug字样
//       home: WelcomePage(),
//      initialRoute: '/welcomePage', //初始化路由
      //命名路由
      onGenerateRoute: onGenerateRoute,
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
